package com.yang.entity.commodityDetail;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.AccessType;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@Document(collection = "specs")
// 当属性为默认值时，不序列化
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
public class Specs implements Serializable, Cloneable {

    /**
     * 规格参数实体类
     */

    @Id
    @JsonIgnore
    private long id; // 参数ID
    private int commodityId; // 商品ID
    private String name; // 商品名称和sku参数名称
    private String valueName; // sku参数值
    private List<Values> values; // 商品参数数据

    @Override
    public String toString() {
        return "Specs{" +
                "id=" + id +
                ", commodityId=" + commodityId +
                ", name='" + name + '\'' +
                ", valueName='" + valueName + '\'' +
                ", values=" + values +
                '}' + "\n";
    }

    @Override
    public Specs clone() {
        try {
            // TODO: 复制此处的可变状态，这样此克隆就不能更改初始克隆的内部项
            return (Specs) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new AssertionError();
        }
    }
}
